<?php
session_start();
/**
Eventos de FrmTableTypes
**/
//Variables de session
$_SESSION['tableTypesIdOrder'];//0 Asc 1 Desc
$_SESSION['tableTypesNombreOrder'];
//-------------------

//MApache
require("../../../weblinx/weblinx.php");
//-------

//----Formularios requeridos----

//------------------------------

//----Clases requeridas---------
require("../../Classes/Setter.php");
require("../../Classes/Sentinel.php");
require("../../Classes/Admin/Type.php");
require("../../Forms/Admin/FrmTableTypes.php");
//-----------------------------

//---Events--------------------

if(isset($_POST['eliminar'])){
	$messageBox=new MessageBox($image="../../../weblinx/Images/danger.png",$messageText="<b>¿Segur@ que quiere eliminar a este tipo de inmueble? <br /> Id: ".$_POST['eliminar']." </b>",$okButtonName="okValidatorFrmTypeEliminar",$okButtonValue="ok",$okButtonEvents=array("onclick"=>"GETMethodSend('idE','okValidatorFrmTypeEliminar','tableTypes','../../Events/Admin/EventsFrmTableTypes.php')"),$cancelButtonName="cancelValidatorFrmTypeEliminar",$cancelButtonValue="cancel",$cancelButtonEvents=array("onclick"=>"GETMethodSend('cancelValidatorFrmTypeEliminar','tableTypes','../../Events/Admin/EventsFrmTableTypes.php')"));
	$messageBox->addHiddenData("idE",$_POST['eliminar']);
	$messageBox->setVisible("visible");
	$messageBox->show();	
}
else if(isset($_GET['okValidatorFrmTypeEliminar'])){
	$type=new Type();
	$type->cargar($_GET['idE']);
	$type->eliminar();
	
	$frmTableTypes=new FrmTableTypes();
	$frmTableTypes->show();
}
else if(isset($_GET['cancelValidatorFrmTypeEliminar'])){
	$frmTableTypes=new FrmTableTypes();
	$frmTableTypes->show();
}


//Ordenamiento por los titulos de la tabla
else if(isset($_POST['id'])){
	if($_SESSION['tableTypesIdOrder']==0){
		$consult="SELECT id,nombre FROM tiposInmueble ORDER BY id ASC";
		$_SESSION['tableTypesIdOrder']=1;
	}
	else{
		$consult="SELECT id,nombre FROM tiposInmueble ORDER BY id DESC";
		$_SESSION['tableTypesIdOrder']=0;
	}
	$frmTableTypes=new FrmTableTypes();
	$frmTableTypes->setDbConsult($consult);
	$frmTableTypes->show();
}

else if(isset($_POST['Nombre'])){
	if($_SESSION['tableTypesNombreOrder']==0){
		$consult="SELECT id,nombre FROM tiposInmueble ORDER BY nombre ASC";
		$_SESSION['tableTypesNombreOrder']=1;
	}
	else{
		$consult="SELECT id,nombre FROM tiposInmueble ORDER BY nombre DESC";
		$_SESSION['tableTypesNombreOrder']=0;
	}
	$frmTableTypes=new FrmTableTypes();
	$frmTableTypes->setDbConsult($consult);
	$frmTableTypes->show();
}

//----------------------------------------

?>